package mc.contents.web;

import mc.contents.web.common.CommonContext;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
 * Created by LuoHui on 14-11-27.
 */
public class AsyncContextFactory {
    private static Map<Long,CommonContext> rankMap = new ConcurrentHashMap<>(  );
    private static Map<Long,CommonContext> reshelfMap = new ConcurrentHashMap<>(  );
    private static Map<String,Map<Long,CommonContext>> map = new HashMap<String,Map<Long,CommonContext>>( 2 ){
        {
            put( "rank",rankMap );
            put( "reshelf",reshelfMap );
        }
    };

    public static synchronized void put( String key, Long id, CommonContext context ){
        map.get( key ).put( id,context );
    }

    public static synchronized CommonContext get( String key,Long id ) {
        return map.get( key ).get( id );
    }

    public static synchronized void remove( String key,Long id ) {
        map.get( key ).remove( id );
    }
}
